<?php

namespace App\Http\Controllers\Web\Seller;

use App\Http\Controllers\Web\BaseController;
use App\Repository\Repositories\Interfaces\OrderQualificationRepository;
use App\Repository\Repositories\Interfaces\OrdersRepository;
use Illuminate\Http\Request;

/**
 * 资质订单管理控制器
 *
 * @package App\Http\Controllers\Backend
 */
class OrderQualificationBidController extends BaseController
{
    /**
     * @var OrdersRepository
     */
    protected $orders_repo;

    protected $user_id;
    protected $shop_id;
    protected $order;

    public function __construct(OrderQualificationRepository $orders_repo,OrdersRepository $order)
    {
        parent::__construct();
        $this->orders_repo = $orders_repo;
        $this->order = $order;
        $this->user_id = array_get($this->user, 'id');
        $this->shop_id =isset($this->user) &&  isset($this->user->shop_id) ? $this->user->shop_id : 0;
    }

  
    public function update(Request $request, $id)
    {
        $this->validate($request, [
            'q_status' => 'required|in:1,2,3,4,5,6,7',
        ]);
        
        $data = $request->all(['q_status']);
        $data['status']=$data['q_status'];
        
        $this->orders_repo->scopeQuery(function ($query){
            return $query->where(['shop_id' => $this->shop_id]);
        });
        
        $ret = $this->orders_repo->update($data, $id);
        
        return $this->noDataReturn($ret);
    }

}
